import java.util.Formatter;
import org.jdom2.Attribute;
import org.jdom2.Element;


public class FantasmaSerializable implements SerializableXML {

	private Fantasma fantasma;
	private String id;
	
	public FantasmaSerializable(Fantasma f,int i){
		this.fantasma = f;
		this.id= Integer.toString(i);
	}
	
	@Override
	public Element SerializarXML() {
		Element element = new Element("Fantasma");
		Attribute att1 = new Attribute("id", this.id );
		Attribute att2 = new Attribute("fila", new Formatter().format("%02d", this.fantasma.posicionActual.getX()).toString());
		Attribute att3 = new Attribute("columna", new Formatter().format("%02d", this.fantasma.posicionActual.getY()).toString());
		Attribute att4 = new Attribute("sentido", this.fantasma.dirActual.name().toLowerCase());
		Attribute att5 = new Attribute("personalidad", this.fantasma.toString());
		
		element.getAttributes().add(att1);
		element.getAttributes().add(att2);
		element.getAttributes().add(att3);
		element.getAttributes().add(att4);
		element.getAttributes().add(att5);
		return element;
	}
}
